/*
 *  testTaskLine.cpp
 *  
 *  Unit testing code for TaskLine using GoogleTest
 */
#include "gtest/gtest.h"
#include "Logic.h"
#include "CommonConstant.h"

TEST(TestDelete, test1)   //@author A0105475H
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("delete 0"), "task 0 has been deleted");
}

TEST(TestDelete, test2)  //@author A0105475H
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("delete 0"), "task 0 has been deleted");
	EXPECT_EQ(logic.executeCommand("delete 0"), CommonConstant::MESSAGE_INVALID_INDEX+"\n"+CommonConstant::MESSAGE_NO_TASK);
}

TEST(TestUpdate, test1)  //@author A0105475H
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("update       "), CommonConstant::MESSAGE_NO_USER_INPUT_AFTER_COMMAND);
}

TEST(TestUpdate, test2)  //@author A0105475H
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("update x"), CommonConstant::MESSAGE_INVALID_INDEX);
}

TEST(TestUpdate, test3)  //@author A0105475H
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("update 10 /t cs2103demo-try"), CommonConstant::MESSAGE_INDEX_OUT_OF_RANGE);
}

TEST(TestUpdate, test4)  //@author A0105475H
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("update 0 /x cs2103demo-try"), CommonConstant::MESSAGE_INVALID_FORMAT);
}

TEST(TestUpdate, test5)  //@author A0105475H
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("update 0 /st 1265"), CommonConstant::MESSAGE_INVALID_TIME_FORMAT);
}

TEST(TestUpdate, test6)  //@author A0105475H
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("update 0 /sd 30/13/2013"), CommonConstant::MESSAGE_INVALID_TIME_FORMAT);
}

TEST(TestUpdate, test7)  //@author A0105475H
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("update 0 /sd feb 29 2013"), CommonConstant::MESSAGE_INVALID_TIME_FORMAT);
}

TEST(TestUpdate, test8)  //@author A0105475H
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("update 0 /st 12:38am"), CommonConstant::MESSAGE_INVALID_TIME_FORMAT);
}

TEST(TestUpdate, test9)  //@author A0105475H
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("update 0 /st  "), CommonConstant::MESSAGE_INVALID_FORMAT);
}

TEST(TestUndo, test1) //@author A0105649B
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	EXPECT_EQ(logic.executeCommand("undo"), "Undo successful: Created task has been deleted.");
}

TEST(TestUndo, test2)  //@author A0105649B
{
	Logic logic;
	EXPECT_EQ(logic.executeCommand("undo"), CommonConstant::MESSAGE_NO_UNDOABLE_TASK);
}

TEST(TestRedo, test1)  //@author A0105649B
{
	Logic logic;
	logic.executeCommand("create /t cs2103demo");
	logic.executeCommand("delete 0");
	EXPECT_EQ(logic.executeCommand("undo"),CommonConstant::MESSAGE_DELETE_UNDO_SUCCESSFULLY);
	EXPECT_EQ(logic.executeCommand("redo"), "task 0 has been deleted");
}

TEST(TestRedo, test2)  //@author A0105649B
{
	Logic logic;
	EXPECT_EQ(logic.executeCommand("redo"), CommonConstant::MESSAGE_NO_REDOABLE_TASK);
}

int main(int argc, char** argv) 
{ 
    testing::InitGoogleTest(&argc, argv); 
    RUN_ALL_TESTS(); 
    std::getchar(); // keep console window open until Return keystroke
}
